'''
{
    caption : {
        prompt..:
        pooled_prompt_..:
        textid_...:
    },
    data : [
        {
            img1: ...
            img1_depth: ...
            img2 : ...
        }
    ]
}
'''
json_files = ['./zhenzhi_yinhua_data.json','./zhenzhi_niukou_data.json',
              './zhenzhi_niukou-pockets_data.json','./zhenzhi_ori_data.json']
import os,json,pdb
from tqdm import tqdm
for json_file in json_files:
    assert(os.path.exists(json_file))
'''
{
    caption : {
        prompt..:
        pooled_prompt_..:
        textid_...:
    },
这一部分保持不变

data中的key 遵循

data_template = {
    'img1':None,
    'img2_texture':None,
    'shape_path':None,
    'concat_img':None,
}

'''
dic = {'caption':None,
       'data':[]}
data_template = {
    'img1':None,
    'img2_texture':None,
    'shape_path':None,
    'concat_img':None,
}

save_path = './zhenzhi_train_data.json'
import copy
for json_file in json_files:
    with open(json_file,'r') as f:
        json_data = json.load(f)
    if dic.get('caption',None) is None:
        dic['caption'] = json_data['caption']
    for jd in tqdm(json_data['data']):
        for k in data_template.keys():
            data_template[k] = jd[k]
        dic['data'].append( copy.deepcopy( data_template  ) )
    # pdb.set_trace()

with open(save_path,'w') as f:
    pdb.set_trace()
    json.dump( dic , f , indent=4 , ensure_ascii=False)